import {
  Tp_categoryValue
} from '@/enumeration/Tp_category.js'
import {
  ApprovalPreview
} from '@/utils/formassembly/buttonservice.js'

export function getBtnText(lable, _this) {
  switch (_this.$route.params.category) {
    case Tp_categoryValue['accept']: {
      return '修改'
    }
    default: {
      return lable
    }
  }
}


// 按钮的点击事件
export function ButtonClick(event, _this) {
  // 事件名称
  let eventName = event.indexOf('(') > -1 ? event.substring(0, event.indexOf('(')) : event
  // 事项传参
  let eventValue = event.substring(event.indexOf('(') + 1, event.lastIndexOf(')'))
  eventValue = eventValue ? JSON.parse(eventValue) : {}
  console.log('ButtonClick', eventName, eventValue)
  switch (eventName) {
    // 变更被申请人
    case 'EditTargetName': {
      _this.$nextTick(() => {
        _this.$refs.editTargetNameRef.f_init(_this.$store.state.Processform.formData)
      })
      break
    }
    // 预览文书
    case 'ApprovalPreview': {
      ApprovalPreview(_this)
      break
    }
    case 'CorrectionPreview': {
      ApprovalPreview(_this)
      break
    }
    // 常用语
    case 'ComwordModal': {
      _this.$nextTick(() => {
        _this.$refs.comwordRef.showModal(eventValue.field)
      })
      break
    }
    // 干预行政复议弹框
    case 'CaseDecisionIntervene': {
      _this.$nextTick(() => {
        _this.$refs.caseDecisionInterveneRef.init()
      })
      break
    }
    default: {
      console.warn('未配置的按钮事件', eventName)
    }
  }
}